<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/tree.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript">
   var currentID='';
   var standardName = null;
   var type = null;
   function selectItem(itemId){
      if(tree.getLevel(itemId)==2){
      	 setChargeItemIdAndType(itemId);
     	 var text = tree.getItemText(itemId);
     	 standardName= text;
         document.all.chargeItemMainFrame.src="${ctx}/charge_chargeStandardAction.do?method=initChargeStandardListBy&chargeItemId="+currentID+"&chargeItemType="+type;
	  }else if(tree.getLevel(itemId)==1){
		 document.all.chargeItemMainFrame.src = "${ctx}/charge_chargeItemAction.do?method=initChargeItemList";
	  }
   }

   function setChargeItemIdAndType(itemId){
   		var index = itemId.indexOf(":");
      	var id = itemId.substring(0,index);
      	type = itemId.substr(index+1);
     	currentID=id;
   }

   function refreshTree(text){
      tree.deleteChildItems(tree.rootId);
	  tree.loadXML("${ctx}/charge_chargeItemAction.do?method=initChargeItemTree",function (){
			tree.openItem();
			if(text == undefined){
				tree.selectItem();
			}else{
				tree.findItem(text,0,1);
			}
			refreshPage();
		});
	}
	function refreshPage(){
		setChargeItemIdAndType(tree.getSelectedItemId());
		if( tree.getLevel(tree.getSelectedItemId()) == 1 ){
			$('chargeItemMainFrame').src =  "${ctx}/charge_chargeItemAction.do?method=initChargeItemList";
		}else if( tree.getLevel(tree.getSelectedItemId()) == 2 ){
			$('chargeItemMainFrame').src =  "${ctx}/charge_chargeStandardAction.do?method=initChargeStandardListBy&chargeItemId="+currentID+"&chargeItemType="+type;
		}
	}
   function rightClickItem(itemId){
	    tree.selectItem(itemId);
	    if(tree.getLevel(itemId)==2){
	       hidden2menu('quick_rightmenu')
	       ShowContextMenu(event,'quick_rightmenu2');
	    } else if(tree.getLevel(itemId)==1){
	       hidden2menu('quick_rightmenu2')
	       ShowContextMenu(event,'quick_rightmenu');
	    }
   }
   function callbackTree(){
       tree.openItem();
	   tree.selectItem();
	   document.all.chargeItemMainFrame.src = "${ctx}/charge_chargeItemAction.do?method=initChargeItemList";
   }
   function openChargeItemAdd(){
      var url = "${ctx}/charge_chargeItemAction.do?method=initChargeItemAdd";
      top.windowOpen(url, "ChargeItemAdd", "${key.addChargeItem}", 400, 500);
   }
   function openChargeItemEdit(tag){
      if(tag == null)
        setChargeItemIdAndType(tree.getSelectedItemId());
      if(currentID == ''){
	     Alert('${key.tipsBySelect}');
	     return false;
	  }
      var url = "${ctx}/charge_chargeItemAction.do?method=initChargeItemEdit&keyword="+currentID;
      top.windowOpen(url, "ChargeItemEdit", "${key.editChargeItem}", 400, 500);
   }
   function showDelete(tag){
   	  if(tag == null)
        setChargeItemIdAndType(tree.getSelectedItemId());
      if(currentID == ''){
	    Alert('${key.tipsBySelect}');
	    return false;
	  }
      AskConfirm("${key.tipsByDeleteConfirm}","main","deleteChargeItem");
   }
   function deleteChargeItem()
   {
   	  var url="${ctx}/charge_chargeItemAction.do?method=deleteChargeItem&keyword="+currentID;
	  var myAjax = new Ajax.Request(
	                   url,
	                   {method: 'post', parameters:"" , onComplete: showResponseDelete}
	                   );
   }
   function showResponseDelete(transport){
		if(transport.responseText=="true"){
			refreshTree();
		}else{
			FailureAlert('${key.doFalse}');
		}
   }
   function setChargeItem(id)
   {
   		currentID = id;
   }
   function getStandardName()
   {
   		return standardName;
   }
   function getChargeItemId()
   {
   		return currentID;
   }
   function getChargeItemType(){
   		return type;
   }

</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="48"><div class="pageNav_bg">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td id="pageNav_leftimg"><img src="${ctx}/images/ico_fc_soufiebiaozhu.gif" width="46" height="47"/></td>
      <td id="navWord"><span class="page_title">${key.chargeTitle}</span></td>
      <td class="pageNav_right"><a href="javascript:showFull_in();"><img id="full_image"  src="${ctx}/images/ico_fullscreen.gif" border="0"/></a></td>
    </tr>
  </table>
</div></td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="19%" valign="top">
	<table width="100%" valign="right" border="0" align="right" cellpadding="0" cellspacing="0"  >
	  <tr>
	    <td  valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="outside_border" >
		 <tr>
	        <td valign="top" ><table width="100%" height="470px" border="0" cellpadding="0" cellspacing="0" id=topadcontent_10>
			  <tr>
	              <td class="bg_toolBar"><table width="100%" border="0" cellspacing="0" cellpadding="0">
	                <tr>
	                  <td width="40%">&nbsp;</td>
	                  <td width="60%" align="right"><!--------------------------右边图标01----------------------------------->
	                    <table border="0" cellpadding="0" cellspacing="0" id="ico3" >
	                      <tr>
	                      <pms:AuthTag authName="charge_chargeItemAction.do?method=initChargeItemAdd">
	                        <td class="toolbarico" ><a href="#"  onclick="openChargeItemAdd();" onfocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" alt="新建" width="16" height="16" border="0" align="absbottom" /></a></td>
	 					</pms:AuthTag>
	 					<pms:AuthTag authName="charge_chargeItemAction.do?method=initChargeItemEdit">
	 						<td class="toolbarico"><a href="#"  onclick="openChargeItemEdit();" onfocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改"/></a></td>
	                    </pms:AuthTag>
	                    <pms:AuthTag authName="charge_chargeItemAction.do?method=deleteChargeItem">
	                        <td class="toolbarico"><a href="#" onClick="showDelete();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="删除" width="16" height="16" border="0" align="absbottom"></a></td>
	                     </pms:AuthTag>
	                       </tr>
	                    </table>
	                   </td>
	                </tr>
	              </table></td>
	            </tr>

	            <tr>
	            <td valign="top">
				<div id="chargeItem_tree" style="overflow:auto;width:100%;height:454px;"></div>
				<script type="text/javascript">
		        try {
		        	var tree=new dhtmlXTreeObject("chargeItem_tree","100%","100%",0);
					tree.setImagePath("${ctx}/images/tree/");
					tree.setOnClickHandler(selectItem);
					tree.setOnRightClickHandler(rightClickItem);
					tree.loadXML("${ctx}/charge_chargeItemAction.do?method=initChargeItemTree",callbackTree);
				} catch(e) {

				}
				</script>
				</td>
	          </tr>
	        </table></td>
	      </tr>
	    </table></td>
	  </tr>
	</table>
	</td>
	<td  width="81%" align="center" valign="top" height="479px">
	  <iframe src="#" name="chargeItemMainFrame" id="chargeItemMainFrame" width="100%"  height="100%"  frameborder="0" border="0"   ></iframe>
	</td>
   </tr>
  </table>

<div id="quick_rightmenu2" style="display:none;" oncontextmenu="return false" class="quick_menu2"
					onMouseOver="showmy2menu('quick_rightmenu2')"  onMouseOut="hidden2menu('quick_rightmenu2')">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="grid_quickMenu_bg">
                      <tr>
                        <td><table width="100%" border="0" cellpadding="2" cellspacing="0">

                            <tr>
                              <td class="quickMenu_toolbarico"><a href="#"  onClick="openChargeItemEdit();" onFocus="this.blur()"><img src="${ctx}/images/ico_amend.gif" border="0" align="absbottom" alt="修改"/>&nbsp;${key.modify}</a></td>
                            </tr>

                            <tr>
                              <td class="quickMenu_toolbarico"><a href="#" onClick="showDelete();" onFocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" alt="" width="16" height="16" border="0" align="absbottom"> ${key.delete}</a></td>
                            </tr>
                        </table></td>
                      </tr>
                    </table>
</div>

<div id="quick_rightmenu" style="display:none;" oncontextmenu="return false" class="quick_menu2" onMouseOver="showmy2menu('quick_rightmenu')"  onMouseOut="hidden2menu('quick_rightmenu')" >
                      <pms:AuthTag authName="charge_chargeItemAction.do?method=initChargeItemAdd">
                      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="grid_quickMenu_bg">
                        <tr>
                          <td><table width="100%" border="0" cellpadding="2" cellspacing="0">
							  <tr>
                                <td class="quickMenu_toolbarico"><a href="#"  onClick="openChargeItemAdd();"onFocus="this.blur()"><img src="${ctx}/images/ico_newfile.gif" border="0" align="absbottom" alt="新建"/>&nbsp;${key.addChargeItem}</a></td>
                              </tr>
                          </table></td>
                        </tr>
                      </table>
                      </pms:AuthTag>
</div>


</body>
</html>
